package org.springblade.modules.platform.algorithm;/*
package com.huateng.algorithm;

import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.ht.utils.AbsoluteDeflection;
import com.ht.utils.BaseStationAlgorithm;
import com.ht.utils.CalModel;
import com.ht.utils.RelativeDeflection;
import com.ht.utils.model.BaseStationDTO;
import com.huateng.dto.AddEquipmentRuningState;

import com.huateng.entity.*;
import com.huateng.service.*;
import com.huateng.vo.DeptBenchInfoSortVO;
import com.huateng.vo.DeptMeasuringInfoVO;
import com.huateng.vo.DeviceTableVO;
import com.huateng.vo.enums.BenchTypeNameEnum;
import com.huateng.vo.enums.ProductTypeEnum;
import io.netty.util.AttributeKey;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Component;

import java.io.BufferedWriter;
import java.io.FileWriter;
import java.io.IOException;
import java.math.BigDecimal;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.nio.file.StandardOpenOption;
import java.util.*;
import java.util.stream.Collectors;

@Component
@AllArgsConstructor
@Slf4j
public class BaseStation {
    private final IDeptInfoTableService iDeptInfoTableService;
    private final IEquipmentLabelService equipmentLabelService;
    private final IDeviceTableService iDeviceTableService;
    private final IPhysicalValueTableService iPhysicalValueTableService;//物理量数据
    private final IEngineerValueTableService iEngineerValueTableService;//工程量
    private final IMeasuringPointTableService iMeasuringPointTableService;//一侧量
    private final IProductModelPropertiesService productModelPropertiesService;
    private final IEquipmentRuningStateService iEquipmentRuningStateService;
    private final IEquipmentLogManagementService equipmentLogManagementService;
    private final IAbsolutelyValueTableService iAbsolutelyValueTableService;
    private static final AttributeKey<String> CONNECTION_ID = AttributeKey.valueOf("connectionId");


    public void installEquipmentRuningState(List<AddEquipmentRuningState> addEquipmentRuningState,Integer gatherEvent) {
        addEquipmentRuningState.forEach(x->{
            Integer deptMeasuringInfoId = x.getDeptMeasuringInfoId();
            BigDecimal rietschlePressure = x.getRietschlePressure();

            DeptInfoTable byId = iDeptInfoTableService.getById(deptMeasuringInfoId);
            DeptMeasuringInfoVO deptMeasuringInfoVO = iDeptInfoTableService.selectDeptMeasuringInfo(deptMeasuringInfoId);
            boolean b = deptMeasuringInfoVO.getMeasuringTypeCode() == 1;
            List<DeptBenchInfoSortVO> deptBenchInfoSortVOS = iDeptInfoTableService.selectDeptBenchInfoByParent(deptMeasuringInfoId);
            if(deptBenchInfoSortVOS != null){
                List<DeptBenchInfoSortVO> collect = deptBenchInfoSortVOS.stream().sorted(Comparator.comparing(DeptBenchInfoSortVO::getSort)).collect(Collectors.toList());
                if(!CollectionUtils.isEmpty(x.getMeasuringPlatform())){
                    List<BaseStationDTO> list = calModel(x.getMeasuringPlatform(), b, collect,x.getAcquisitionTime(),x.getDeptMeasuringInfoId());
                    for (int i=list.size()-1;i>=0;i--) {
                        BaseStationDTO l = list.get(i);
                        PhysicalValueTable physicalValueTable = new PhysicalValueTable();
                        physicalValueTable.setGatherTime(x.getAcquisitionTime());
                        physicalValueTable.setGatherEvent(gatherEvent);
                        physicalValueTable.setMeasurChainCode(Long.parseLong(deptMeasuringInfoId.toString()));
                        physicalValueTable.setMeasurChain(byId.getDeptName());
                        physicalValueTable.setMeasurChainDirection(deptMeasuringInfoVO.getMeasuringTypeCode());
                        physicalValueTable.setMeasurChainDirectionName(deptMeasuringInfoVO.getMeasureTypeEnum());
                        physicalValueTable.setInsertTime(System.currentTimeMillis());
                        physicalValueTable.setBenchTypeCode(l.getBenchTypeCode());
                        physicalValueTable.setBenchTypeName(l.getBenchTypeName());
                        physicalValueTable.setDeptId(Long.parseLong(l.getDeptId().toString()));
                        physicalValueTable.setDeptName(l.getDeptName());
                        BaseStationDTO.PhysicalQuantityDTO physicalQuantityDTO = l.getPhysicalQuantityDTO();
                        if(physicalQuantityDTO!=null){
                            physicalValueTable.setzX(physicalQuantityDTO.getZX());
                            physicalValueTable.setzZ(physicalQuantityDTO.getZZ());
                            physicalValueTable.setnX(physicalQuantityDTO.getNX());
                            physicalValueTable.setnZ(physicalQuantityDTO.getNZ());
                            physicalValueTable.setDeltaY(physicalQuantityDTO.getDeltaY());
                            physicalValueTable.setDipX(physicalQuantityDTO.getDipX());
                            physicalValueTable.setDipY(physicalQuantityDTO.getDipY());
                            physicalValueTable.setCcd1FrontDipX(Integer.parseInt(physicalQuantityDTO.getCcd1FrontDipx()+""));
                            physicalValueTable.setCcd1AfterDipX(Integer.parseInt(physicalQuantityDTO.getCcd1AfterDipx()+""));

                            iPhysicalValueTableService.save(physicalValueTable);
                        }
                        EngineerValueTable engineerValueTable = new EngineerValueTable();
                        engineerValueTable.setGatherTime(x.getAcquisitionTime());
                        engineerValueTable.setGatherEvent(gatherEvent);
                        engineerValueTable.setMeasurChainCode(Long.parseLong(deptMeasuringInfoId.toString()));
                        engineerValueTable.setMeasurChain(byId.getDeptName());
                        engineerValueTable.setMeasurChainDirection(deptMeasuringInfoVO.getMeasuringTypeCode());
                        engineerValueTable.setMeasurChainDirectionName(deptMeasuringInfoVO.getMeasureTypeEnum());
                        engineerValueTable.setInsertTime(System.currentTimeMillis());
                        engineerValueTable.setBenchTypeCode(l.getBenchTypeCode());
                        engineerValueTable.setBenchTypeName(l.getBenchTypeName());
                        engineerValueTable.setDeptId(Long.parseLong(l.getDeptId().toString()));
                        engineerValueTable.setDeptName(l.getDeptName());
                        BaseStationDTO.AbsoluteValueDTO absoluteValueDTO = l.getAbsoluteValueDTO();
                        if(null != absoluteValueDTO){
                            engineerValueTable.setX(absoluteValueDTO.getX());
                            engineerValueTable.setY(absoluteValueDTO.getY());
                            engineerValueTable.setZ(absoluteValueDTO.getZ());
                            engineerValueTable.setAlpha(absoluteValueDTO.getAlpha());
                            engineerValueTable.setBeta(absoluteValueDTO.getBeta());
                            engineerValueTable.setGama(absoluteValueDTO.getGama());
                            iEngineerValueTableService.save(engineerValueTable);
                        }
                        List<BaseStationDTO.OnceValueDTO> onceValueDTO = l.getOnceValueDTO();
                        if(!CollectionUtils.isEmpty(onceValueDTO)){
                            for (int i1=onceValueDTO.size()-1;i1>=0;i1--) {

                                BaseStationDTO.OnceValueDTO l1 = onceValueDTO.get(i1);
                                MeasuringPointTable measuringPointTable = new MeasuringPointTable();
                                measuringPointTable.setGatherTime(x.getAcquisitionTime());
                                measuringPointTable.setGatherEvent(gatherEvent);
                                measuringPointTable.setMeasurChainCode(Long.parseLong(deptMeasuringInfoId.toString()));
                                measuringPointTable.setMeasurChain(byId.getDeptName());
                                measuringPointTable.setMeasurChainDirection(deptMeasuringInfoVO.getMeasuringTypeCode());
                                measuringPointTable.setMeasurChainDirectionName(deptMeasuringInfoVO.getMeasureTypeEnum());
                                measuringPointTable.setInsertTime(System.currentTimeMillis());
                                measuringPointTable.setBenchTypeCode(l.getBenchTypeCode());
                                measuringPointTable.setBenchTypeName(l.getBenchTypeName());
                                measuringPointTable.setDeptId(Long.parseLong(l.getDeptId().toString()));
                                measuringPointTable.setDeptName(l.getDeptName());
                                measuringPointTable.setDeviceId(l1.getDeviceId());
                                measuringPointTable.setDeviceName(l1.getDeviceName());
                                measuringPointTable.setPropertieId(l1.getPropertieId());
                                measuringPointTable.setPropertieName(l1.getPropertieName());
                                measuringPointTable.setOnceValue(Integer.valueOf(l1.getOnceValue()));
                                measuringPointTable.setInsertTime(System.currentTimeMillis());
                                measuringPointTable.setRietschlePressure(rietschlePressure);
                                iMeasuringPointTableService.save(measuringPointTable);
                            }
                        }
                    }
                }

            }
        });
    }



    private List<BaseStationDTO> calModel(List<AddEquipmentRuningState.MeasuringPlatformDTO> measuringPlatform,Boolean dir,List<DeptBenchInfoSortVO> deptBenchInfoSortVOS,Long acquisitionTime,Long deptMeasuringInfoId){
        List<BaseStationDTO> list = new ArrayList<>();
        Map<Integer,BaseStationDTO.AbsoluteValueDTO> integerPhysicalQuantityDTOMap = new HashMap<>();
        Map<Integer,BaseStationDTO.PhysicalQuantityDTO> integerPhysicalQuantityDTOHashMap = new HashMap<>();
        List<DeptBenchInfoSortVO> collect = deptBenchInfoSortVOS.stream()
                .filter(x -> x.getBenchTypeCode() == BenchTypeNameEnum.ORDINARY.getCode()).sorted(Comparator.comparing(DeptBenchInfoSortVO::getSort))
                .collect(Collectors.toList());
        DeptBenchInfoSortVO deptBenchInfoSortVO1 = collect.get(0);

        Double dipX_6 = null;
        Double dipY_6 = null;
        for (DeptBenchInfoSortVO deptBenchInfoSortVO : deptBenchInfoSortVOS) {
            BaseStationDTO baseStationDTO = new BaseStationDTO();
            baseStationDTO.setDeptId(deptBenchInfoSortVO.getId());
            baseStationDTO.setDeptName(deptBenchInfoSortVO.getDeptName());
            baseStationDTO.setBenchTypeCode(deptBenchInfoSortVO.getBenchTypeCode());
            baseStationDTO.setBenchTypeName(deptBenchInfoSortVO.getBenchTypeNameEnum());

            AddEquipmentRuningState.MeasuringPlatformDTO measuringPlatformDTO = measuringPlatform.stream().filter(l -> Objects.equals(l.getMeasuringPlatformCode(), deptBenchInfoSortVO.getId())).findFirst().get();
            Integer previousTypeCode = deptBenchInfoSortVO.getParentBench();//父级测台的编号

            List<BaseStationDTO.OnceValueDTO> onceValue = getOnceValue(measuringPlatformDTO.getDeviceList(),acquisitionTime);
            baseStationDTO.setOnceValueDTO(onceValue);


            switch (BenchTypeNameEnum.getEnum(deptBenchInfoSortVO.getBenchTypeCode())){
                case ORDINARY://一般测台
                    AddEquipmentRuningState.MeasuringPlatformDTO.DeviceListDTO x = measuringPlatformDTO.getDeviceList().get(0);
                    String deviceId = x.getDeviceId();
                    List<EquipmentLabel> equipmentLabels = equipmentLabelService.list(Wrappers.<EquipmentLabel>query().lambda()
                            .eq(EquipmentLabel::getEquipmentId, deviceId));
                    AddEquipmentRuningState.MeasuringPlatformDTO measuringPlatformDTO1 = measuringPlatform.stream().filter(l -> Objects.equals(l.getMeasuringPlatformCode(), previousTypeCode)).findFirst().get();
                    BaseStationDTO.PhysicalQuantityDTO physicalQuantity = getPhysicalQuantity(dir,x.getAttributeListDTO(),equipmentLabels,measuringPlatformDTO1, deviceId);//当前测台的物理量
                    baseStationDTO.setPhysicalQuantityDTO(physicalQuantity);
                    AbsolutelyValueTable one = iAbsolutelyValueTableService.getOne(Wrappers.<AbsolutelyValueTable>lambdaQuery()
                                .eq(AbsolutelyValueTable::getDeptId, deptBenchInfoSortVO.getId())
                                .eq(AbsolutelyValueTable::getMeasurChainCode, deptMeasuringInfoId));
                    if(one==null){
                        physicalQuantity.setDipX(0.0);
                        one = new AbsolutelyValueTable();
                        BeanUtils.copyProperties(physicalQuantity, one);
                        one.setMeasurChainCode(deptMeasuringInfoId);
                        one.setDeptId(deptBenchInfoSortVO.getId().toString());
                        one.setCcd1AfterDipX(Integer.parseInt(physicalQuantity.getCcd1AfterDipx()+""));
                        one.setCcd1FrontDipX(Integer.parseInt(physicalQuantity.getCcd1FrontDipx()+""));
                        one.setCcd2AfterDipY(Integer.parseInt(physicalQuantity.getCcd2AfterDipy()+""));
                        one.setCcd2FrontDipY(Integer.parseInt(physicalQuantity.getCcd2FrontDipy()+""));
                        one.setY(physicalQuantity.getY());
                        iAbsolutelyValueTableService.save(one);
                    }
                    physicalQuantity.setDeltaY(physicalQuantity.getDeltaY() - one.getDeltaY());
                    physicalQuantity.setZX(physicalQuantity.getZX() - one.getzX());
                    physicalQuantity.setNX(physicalQuantity.getNX() - one.getnX());
                    physicalQuantity.setNZ(physicalQuantity.getNZ() - one.getnZ());
                    physicalQuantity.setZZ(physicalQuantity.getZZ()- one.getzZ());
                    physicalQuantity.setCcd1FrontDipx(physicalQuantity.getCcd1FrontDipx() - one.getCcd1FrontDipX());
                    physicalQuantity.setCcd1AfterDipx(physicalQuantity.getCcd1AfterDipx() - one.getCcd1AfterDipX());

                    physicalQuantity.setCcd2AfterDipy(physicalQuantity.getCcd2AfterDipy() - one.getCcd2AfterDipY());
                    physicalQuantity.setCcd2FrontDipy(physicalQuantity.getCcd2FrontDipy() - one.getCcd2FrontDipY());
                    Double ccd2AfterDipy = physicalQuantity.getCcd2AfterDipy();//当前
                    Double ccd2FrontDipy = physicalQuantity.getCcd2FrontDipy();
                    Double beta = (ccd2FrontDipy + ccd2AfterDipy) / 2 * 0.0047 / 2000;
                    physicalQuantity.setDipY(beta);
                    Double ccd1AfterDipx1 = physicalQuantity.getCcd1AfterDipx();//当前
                    Double ccd1FrontDipx1 = physicalQuantity.getCcd1FrontDipx();
                    Double dipX = (ccd1AfterDipx1 + ccd1FrontDipx1) / 2 * 0.0047 / 2000;
                    physicalQuantity.setDipX(dipX);
                    physicalQuantity.setY(physicalQuantity.getY()-one.getY());
                    integerPhysicalQuantityDTOHashMap.put(deptBenchInfoSortVO.getId(),physicalQuantity);
                    BaseStationDTO.AbsoluteValueDTO absoluteValue = new BaseStationDTO.AbsoluteValueDTO();
                    if(dir){//计算正向
                        if(deptBenchInfoSortVO.getId()==6){
                            dipX_6 = (ccd1AfterDipx1 + ccd1FrontDipx1) / 2 * 0.0047 / 4000;
                            dipY_6 = (ccd2FrontDipy + ccd2AfterDipy) / 2 * 0.0047 / 4000;
                            break;
                        }
                        if(deptBenchInfoSortVO.getId()==5){
                            absoluteValue.setZ(0.0);
                            absoluteValue.setY(0.0);
                            absoluteValue.setX(0.0);
                            absoluteValue.setGama(0.0);
                            physicalQuantity.setDipX(dipX_6);
                            physicalQuantity.setDipY(dipY_6);
                            absoluteValue.setBeta(dipY_6);//6
                            absoluteValue.setAlpha(dipX_6);//6
                            integerPhysicalQuantityDTOMap.put(deptBenchInfoSortVO.getId(),absoluteValue);
                            baseStationDTO.setAbsoluteValueDTO(absoluteValue);
                            break;
                        }
                    }else {//计算逆向
                        if(Objects.equals(deptBenchInfoSortVO.getId(), deptBenchInfoSortVO1.getId())){

                            absoluteValue.setZ(0.0);
                            absoluteValue.setY(0.0);
                            absoluteValue.setX(0.0);
                            absoluteValue.setGama(0.0);

                            //absoluteValue.setBeta(beta);//6
                            //absoluteValue.setAlpha(dipX);//6
                            absoluteValue.setBeta(0.0);//6
                            absoluteValue.setAlpha(0.0);//6
                            integerPhysicalQuantityDTOMap.put(deptBenchInfoSortVO.getId(),absoluteValue);
                            baseStationDTO.setAbsoluteValueDTO(absoluteValue);
                            log.info("1号测台工程量:{}",absoluteValue);
                            break;

                        }

                    }

                    CalModel calModel = new CalModel();
                    AbsoluteDeflection parentDeflect = new AbsoluteDeflection();
                    BaseStationDTO.AbsoluteValueDTO absoluteValueDTO = integerPhysicalQuantityDTOMap.get(previousTypeCode);//上个测台的工程量
                    parentDeflect.setX(absoluteValueDTO.getX());
                    parentDeflect.setY(absoluteValueDTO.getY());
                    parentDeflect.setZ(absoluteValueDTO.getZ());
                    parentDeflect.setBeta(absoluteValueDTO.getBeta());
                    parentDeflect.setAlpha(absoluteValueDTO.getAlpha());
                    parentDeflect.setGama(absoluteValueDTO.getGama());


                    AbsoluteDeflection childDeflect = new AbsoluteDeflection();
                    childDeflect.setBeta(physicalQuantity.getDipY());

                    RelativeDeflection relativeDeflect = new RelativeDeflection();//物理量

                    relativeDeflect.setNX(physicalQuantity.getNX());
                    relativeDeflect.setNZ(physicalQuantity.getNZ());
                    relativeDeflect.setZX(physicalQuantity.getZX());
                    relativeDeflect.setZZ(physicalQuantity.getZZ());


                    if(!dir){//如果是逆向的时候DeltaY取父级测台的DeltaY
                        BaseStationDTO.PhysicalQuantityDTO physicalQuantityDTO = integerPhysicalQuantityDTOHashMap.get(previousTypeCode);//上一个测台物理量
                        relativeDeflect.setDeltaY(physicalQuantityDTO.getY());
                    }else {
                        relativeDeflect.setDeltaY(physicalQuantity.getDeltaY());
                    }

                    String fileName = "/home/wangl/Desktop/newFile.txt";
                    Path path = Paths.get(fileName);
                    //追加写模式
                    try (BufferedWriter writer =
                                 Files.newBufferedWriter(path,
                                         StandardCharsets.UTF_8,
                                         StandardOpenOption.APPEND)){
                        writer.write("\n");
                        writer.write("模型入参测台编号:"+deptBenchInfoSortVO.getId()+";dir:"+ dir + "\n"
                                +",parentDeflect:"+parentDeflect.toString() + "\n"
                                +",childDeflect："+childDeflect+ "\n"
                                +",relativeDeflect:"+relativeDeflect+ "\n"
                                +",theta:"+deptBenchInfoSortVO.getYAxis()+ "\n"
                                +",childLen:"+deptBenchInfoSortVO.getPreviousDistance()+ "\n"
                                +",fai:"+ deptBenchInfoSortVO.getXAxis()+
                                "\n");


                        AbsoluteDeflection cal = calModel.cal(dir,
                                parentDeflect,
                                childDeflect,
                                relativeDeflect,
                                deptBenchInfoSortVO.getYAxis(),
                                deptBenchInfoSortVO.getPreviousDistance(),//父级的长度
                                deptBenchInfoSortVO.getXAxis());
                        writer.write("模型输出:"+cal.toString()+
                                "\n");
                        absoluteValue.setAlpha(cal.getAlpha());
                        absoluteValue.setBeta(cal.getBeta());
                        absoluteValue.setGama(cal.getGama());
                        absoluteValue.setX(cal.getX());
                        absoluteValue.setY(cal.getY());
                        absoluteValue.setZ(cal.getZ());
                        absoluteValue.setAlpha(cal.getAlpha());
                        integerPhysicalQuantityDTOMap.put(deptBenchInfoSortVO.getId(),absoluteValue);
                        baseStationDTO.setAbsoluteValueDTO(absoluteValue);
                    }catch (Exception e){

                    }
                    break;
                case BASICS://基点测台
                    baseStationDTO.setPhysicalQuantityDTO(null);//物理量
                    BaseStationDTO.AbsoluteValueDTO absoluteValue1 = getAbsoluteValue(measuringPlatformDTO.getDeviceList());//绝对量
                    integerPhysicalQuantityDTOMap.put(deptBenchInfoSortVO.getId(),absoluteValue1);
                    baseStationDTO.setAbsoluteValueDTO(absoluteValue1);
                    break;
            }

            list.add(baseStationDTO);
        }
        return list;
    }

    private List<BaseStationDTO.OnceValueDTO> getOnceValue(List<AddEquipmentRuningState.MeasuringPlatformDTO.DeviceListDTO> deviceListDTOS,Long acquisitionTime){
        List<BaseStationDTO.OnceValueDTO> onceValueDTOS = new ArrayList<>();
        deviceListDTOS.forEach(x->{
            DeviceTableVO deviceTableVO = iDeviceTableService.selectDeviceById(x.getDeviceId());
            EquipmentRuningState equipmentRuningState4 = new EquipmentRuningState();
            equipmentRuningState4.setEquipmentId(deviceTableVO.getDeviceId());
            equipmentRuningState4.setInsertTime(acquisitionTime);
            equipmentRuningState4.setUpdateTime(acquisitionTime);
            ProductModelProperties productModelProperties = productModelPropertiesService.getOne(new QueryWrapper<ProductModelProperties>().lambda()
                    .eq(ProductModelProperties::getProductId,deviceTableVO.getProductId()));
            String propertiesJson = productModelProperties.getPropertiesJson();
            JSONArray jsonArray = JSONArray.parseArray(propertiesJson);
            JSONObject jsonObject = new JSONObject();
            List<AddEquipmentRuningState.MeasuringPlatformDTO.DeviceListDTO.AttributeListDTO> attributeListDTO1 = x.getAttributeListDTO();
            attributeListDTO1.forEach(l->{
                EquipmentRuningState equipmentRuningState1 = new EquipmentRuningState();
                equipmentRuningState1.setEquipmentId(deviceTableVO.getDeviceId());
                equipmentRuningState1.setInsertTime(acquisitionTime);
                equipmentRuningState1.setUpdateTime(acquisitionTime);
                equipmentRuningState1.setPropertieId(l.getKey());
                Map<String, Object> map = new HashMap<>();
                map.put(l.getKey(), l.getValue());
                equipmentRuningState1.setJsonText(JSONObject.toJSONString(map));
                iEquipmentRuningStateService.remove(Wrappers.<EquipmentRuningState>query().lambda().eq(EquipmentRuningState::getEquipmentId, deviceTableVO.getDeviceId()).eq(EquipmentRuningState::getPropertieId, l.getKey()));
                iEquipmentRuningStateService.save(equipmentRuningState1);
                jsonObject.put(l.getKey(), l.getValue());
                BaseStationDTO.OnceValueDTO onceValueDTO = new BaseStationDTO.OnceValueDTO();
                onceValueDTO.setDeviceId(x.getDeviceId());
                onceValueDTO.setDeviceName(deviceTableVO.getDeviceName());
                onceValueDTO.setPropertieId(l.getKey());
                onceValueDTO.setOnceValue(l.getValue()+"");
                Optional<Object> id = jsonArray.stream().filter(j -> ((JSONObject) j).get("id").toString().equalsIgnoreCase(l.getKey())).findFirst();
                if(id.isPresent()){
                    JSONObject o = (JSONObject) id.get();
                    onceValueDTO.setPropertieName(o.get("name").toString());
                }
                onceValueDTOS.add(onceValueDTO);
            });
            equipmentRuningState4.setJsonText(jsonObject.toJSONString());
            iEquipmentRuningStateService.insertEquipmentRuningState(equipmentRuningState4);
            EquipmentLogManagement equipmentLogManagement = new EquipmentLogManagement();
            equipmentLogManagement.setCmd("cmd");
            equipmentLogManagement.setCmdSeq(System.currentTimeMillis()+"");
            equipmentLogManagement.setEquipmentId(x.getDeviceId());
            equipmentLogManagement.setCreateTime(System.currentTimeMillis());
            equipmentLogManagement.setIsDeleted(0);
            equipmentLogManagement.setLogType(1);
            equipmentLogManagement.setPullMessageContent(x.getAttributeListDTO().toString());
            equipmentLogManagement.setPullMessageTime(System.currentTimeMillis());
            equipmentLogManagementService.save(equipmentLogManagement);
        });
        return onceValueDTOS;

    }


    private BaseStationDTO.PhysicalQuantityDTO getPhysicalQuantity(Boolean dir,List<AddEquipmentRuningState.MeasuringPlatformDTO.DeviceListDTO.AttributeListDTO> attributeListDTO
            ,List<EquipmentLabel> equipmentLabels,AddEquipmentRuningState.MeasuringPlatformDTO parentMeasuringPlatform,String deviceId){
        if(dir){
            BaseStationDTO.PhysicalQuantityDTO physicalQuantityDTO = new BaseStationDTO.PhysicalQuantityDTO();
            List<AddEquipmentRuningState.MeasuringPlatformDTO.DeviceListDTO> deviceList = parentMeasuringPlatform.getDeviceList();
            BaseStationAlgorithm baseStationAlgorithm = new BaseStationAlgorithm();
            if(deviceList.size()>1){//1号测台
                log.info("1号测台物理量");
                physicalQuantityDTO.setNX(0.0);
                physicalQuantityDTO.setNZ(0.0);
                physicalQuantityDTO.setZX(0.0);
                physicalQuantityDTO.setZZ(0.0);

                physicalQuantityDTO.setDeltaY(0.0);// 铟钢管的相对变形量( 0.0047*（CCD3后沿+CCD3前沿）/2)


                Double ccd3_after_tangential_y = attributeListDTO.stream().filter(x -> x.getKey().equalsIgnoreCase("ccd3_after_tangential_y")).findFirst().get().getValue().doubleValue();
                Double ccd3_front_tangential_y = attributeListDTO.stream().filter(x -> x.getKey().equalsIgnoreCase("ccd3_front_tangential_y")).findFirst().get().getValue().doubleValue();
                //Double deltaY = getDeformation(ccd3_after_tangential_y,ccd3_front_tangential_y);
                Double y = baseStationAlgorithm.getDeformation(ccd3_after_tangential_y,ccd3_front_tangential_y);
                physicalQuantityDTO.setY(y);// 铟钢管的相对变形量( 0.0047*（CCD3后沿+CCD3前沿）/2)



                Double ccd1_after_dip_x = attributeListDTO.stream().filter(x -> x.getKey().equalsIgnoreCase("ccd2_after_dip_y")).findFirst().get().getValue().doubleValue();
                physicalQuantityDTO.setCcd1AfterDipx(ccd1_after_dip_x);

                Double ccd1_front_dip_x = attributeListDTO.stream().filter(x -> x.getKey().equalsIgnoreCase("ccd2_front_dip_y")).findFirst().get().getValue().doubleValue();
                physicalQuantityDTO.setCcd1FrontDipx(ccd1_front_dip_x);



                Double ccd2_after_dip_y = attributeListDTO.stream().filter(x -> x.getKey().equalsIgnoreCase("ccd1_after_dip_x")).findFirst().get().getValue().doubleValue();
                Double ccd2_front_dip_y = attributeListDTO.stream().filter(x -> x.getKey().equalsIgnoreCase("ccd1_front_dip_x")).findFirst().get().getValue().doubleValue();
                physicalQuantityDTO.setCcd2AfterDipy(ccd2_after_dip_y);
                physicalQuantityDTO.setCcd2FrontDipy(ccd2_front_dip_y);


                //String dip_x_k = equipmentLabels.stream().filter(x -> x.getPropertieCode().equalsIgnoreCase("dip_x_K")).findFirst().get().getPropertieValue();
                //String dip_x_B = equipmentLabels.stream().filter(x -> x.getPropertieCode().equalsIgnoreCase("dip_x_B")).findFirst().get().getPropertieValue();
                // Double dipX = baseStationAlgorithm.getBate(Double.valueOf(dip_x_k), ccd1_after_dip_x, ccd1_front_dip_x, Double.valueOf(dip_x_B));
                //physicalQuantityDTO.setDipX(dipX);//倾角X(K*（后沿+前沿）/2 + B)
                //physicalQuantityDTO.setDipY(0.0);//倾角Y(作为计算绝对量的beta角输入)
                log.info("1号测台物理量:{}",physicalQuantityDTO);
            }else {

                Double ccd1_x_after_forward = attributeListDTO.stream().filter(x -> x.getKey().equalsIgnoreCase("ccd1_x_front_forward")).findFirst().get().getValue().doubleValue();
                Double ccd1_x_front_forward = attributeListDTO.stream().filter(x -> x.getKey().equalsIgnoreCase("ccd1_x_after_forward")).findFirst().get().getValue().doubleValue();
                Double ccd4_x_after_forward = attributeListDTO.stream().filter(x -> x.getKey().equalsIgnoreCase("ccd4_x_after_forward")).findFirst().get().getValue().doubleValue();
                Double ccd4_x_front_forward = attributeListDTO.stream().filter(x -> x.getKey().equalsIgnoreCase("ccd4_x_front_forward")).findFirst().get().getValue().doubleValue();
                //Double zx = getPhysicalQuantityFormula(ccd1_x_after_forward, ccd1_x_front_forward, ccd4_x_after_forward, ccd4_x_front_forward);
                Double zx = baseStationAlgorithm.getPhysicalQuantityFormula(ccd1_x_after_forward, ccd1_x_front_forward, ccd4_x_after_forward, ccd4_x_front_forward);

                physicalQuantityDTO.setZX(zx);//正向光束的X方向相对变形量(0.0047*（（CCD1后沿+CCD1前沿）+（CCD4后沿+CCD4前沿））/2)

                Double ccd2_z_after_forward = attributeListDTO.stream().filter(x -> x.getKey().equalsIgnoreCase("ccd2_z_after_forward")).findFirst().get().getValue().doubleValue();
                Double ccd2_z_front_forward = attributeListDTO.stream().filter(x -> x.getKey().equalsIgnoreCase("ccd2_z_front_forward")).findFirst().get().getValue().doubleValue();
                Double ccd3_z_after_forward = attributeListDTO.stream().filter(x -> x.getKey().equalsIgnoreCase("ccd3_z_after_forward")).findFirst().get().getValue().doubleValue();
                Double ccd3_z_front_forward = attributeListDTO.stream().filter(x -> x.getKey().equalsIgnoreCase("ccd3_z_front_forward")).findFirst().get().getValue().doubleValue();
                //Double zz = getPhysicalQuantityFormula(ccd2_z_after_forward, ccd2_z_front_forward, ccd3_z_after_forward, ccd3_z_front_forward);
                Double zz = baseStationAlgorithm.getPhysicalQuantityFormula(ccd2_z_after_forward, ccd2_z_front_forward, ccd3_z_after_forward, ccd3_z_front_forward);
                physicalQuantityDTO.setZZ(zz);//正向光束的Z方向相对变形量( 0.0047*（（CCD2后沿+CCD2前沿）+（CCD3后沿+CCD3前沿））/2)

                AddEquipmentRuningState.MeasuringPlatformDTO.DeviceListDTO dto = parentMeasuringPlatform.getDeviceList().get(0);
                List<AddEquipmentRuningState.MeasuringPlatformDTO.DeviceListDTO.AttributeListDTO> parentDTO = dto.getAttributeListDTO();
                Double ccd1_x_after_backward = parentDTO.stream().filter(x -> x.getKey().equalsIgnoreCase("ccd1_x_after_backward")).findFirst().get().getValue().doubleValue();
                Double ccd1_x_front_backward = parentDTO.stream().filter(x -> x.getKey().equalsIgnoreCase("ccd1_x_front_backward")).findFirst().get().getValue().doubleValue();
                Double ccd4_x_after_backward = parentDTO.stream().filter(x -> x.getKey().equalsIgnoreCase("ccd4_x_after_backward")).findFirst().get().getValue().doubleValue();
                Double ccd4_x_front_backward = parentDTO.stream().filter(x -> x.getKey().equalsIgnoreCase("ccd4_x_front_backward")).findFirst().get().getValue().doubleValue();
                Double nx = baseStationAlgorithm.getPhysicalQuantityFormula(ccd1_x_after_backward, ccd1_x_front_backward, ccd4_x_after_backward, ccd4_x_front_backward);
                physicalQuantityDTO.setNX(nx);//逆向光束的X方向相对变形量(0.0047*（（CCD1后沿+CCD1前沿）+（CCD4后沿+CCD4前沿））/2)
                Double ccd2_z_after_backward = parentDTO.stream().filter(x -> x.getKey().equalsIgnoreCase("ccd2_z_after_backward")).findFirst().get().getValue().doubleValue();
                Double ccd2_z_front_backward = parentDTO.stream().filter(x -> x.getKey().equalsIgnoreCase("ccd2_z_front_backward")).findFirst().get().getValue().doubleValue();
                Double ccd3_z_after_backward = parentDTO.stream().filter(x -> x.getKey().equalsIgnoreCase("ccd3_z_after_backward")).findFirst().get().getValue().doubleValue();
                Double ccd3_z_front_backward = parentDTO.stream().filter(x -> x.getKey().equalsIgnoreCase("ccd3_z_front_backward")).findFirst().get().getValue().doubleValue();
                Double nz = baseStationAlgorithm.getPhysicalQuantityFormula(ccd2_z_after_backward, ccd2_z_front_backward, ccd3_z_after_backward, ccd3_z_front_backward);
                physicalQuantityDTO.setNZ(nz);//逆向光束的Z方向相对变形量(0.0047*（（CCD2后沿+CCD2前沿）+（CCD3后沿+CCD3前沿））/2)


                Double ccd3_after_tangential_y = attributeListDTO.stream().filter(x -> x.getKey().equalsIgnoreCase("ccd3_after_tangential_y")).findFirst().get().getValue().doubleValue();
                Double ccd3_front_tangential_y = attributeListDTO.stream().filter(x -> x.getKey().equalsIgnoreCase("ccd3_front_tangential_y")).findFirst().get().getValue().doubleValue();
                //Double deltaY = getDeformation(ccd3_after_tangential_y,ccd3_front_tangential_y);
                Double deltaY = baseStationAlgorithm.getDeformation(ccd3_after_tangential_y,ccd3_front_tangential_y);
                physicalQuantityDTO.setDeltaY(deltaY);// 铟钢管的相对变形量( 0.0047*（CCD3后沿+CCD3前沿）/2)(4-5  用4)（5-4  用4）
                physicalQuantityDTO.setY(deltaY);//4-

                //Double ccd1_after_dip_x = attributeListDTO.stream().filter(x -> x.getKey().equalsIgnoreCase("ccd1_after_dip_x")).findFirst().get().getValue().doubleValue();
                //Double ccd1_front_dip_x = attributeListDTO.stream().filter(x -> x.getKey().equalsIgnoreCase("ccd1_front_dip_x")).findFirst().get().getValue().doubleValue();
                //String dip_x_k = equipmentLabels.stream().filter(x -> x.getPropertieCode().equalsIgnoreCase("dip_x_K")).findFirst().get().getPropertieValue();
                //String dip_x_B = equipmentLabels.stream().filter(x -> x.getPropertieCode().equalsIgnoreCase("dip_x_B")).findFirst().get().getPropertieValue();
                //Double dipX = baseStationAlgorithm.getBate(Double.valueOf(dip_x_k), ccd1_after_dip_x, ccd1_front_dip_x, Double.valueOf(dip_x_B));
                //physicalQuantityDTO.setDipX(dipX);//倾角X(K*（后沿+前沿）/2 + B)


                Double ccd1_after_dip_x = attributeListDTO.stream().filter(x -> x.getKey().equalsIgnoreCase("ccd2_after_dip_y")).findFirst().get().getValue().doubleValue();
                physicalQuantityDTO.setCcd1AfterDipx(ccd1_after_dip_x);

                Double ccd1_front_dip_x = attributeListDTO.stream().filter(x -> x.getKey().equalsIgnoreCase("ccd2_front_dip_y")).findFirst().get().getValue().doubleValue();
                physicalQuantityDTO.setCcd1FrontDipx(ccd1_front_dip_x);


                Double ccd2_after_dip_y = attributeListDTO.stream().filter(x -> x.getKey().equalsIgnoreCase("ccd1_after_dip_x")).findFirst().get().getValue().doubleValue();
                Double ccd2_front_dip_y = attributeListDTO.stream().filter(x -> x.getKey().equalsIgnoreCase("ccd1_front_dip_x")).findFirst().get().getValue().doubleValue();
                physicalQuantityDTO.setCcd2AfterDipy(ccd2_after_dip_y);
                physicalQuantityDTO.setCcd2FrontDipy(ccd2_front_dip_y);


                //String dip_y_k = equipmentLabels.stream().filter(x -> x.getPropertieCode().equalsIgnoreCase("dip_y_K")).findFirst().get().getPropertieValue();
                //String dip_y_B = equipmentLabels.stream().filter(x -> x.getPropertieCode().equalsIgnoreCase("dip_y_B")).findFirst().get().getPropertieValue();


                //Double dipY = baseStationAlgorithm.getBate(Double.valueOf(dip_y_k), ccd2_after_dip_y, ccd2_front_dip_y, Double.valueOf(dip_y_B));



                //physicalQuantityDTO.setDipY(dipY);//倾角Y(作为计算绝对量的beta角输入)
                log.info("大于1号测台物理量:{}",physicalQuantityDTO);
            }
            return physicalQuantityDTO;
        }else {
            BaseStationDTO.PhysicalQuantityDTO physicalQuantityDTO = new BaseStationDTO.PhysicalQuantityDTO();
            List<AddEquipmentRuningState.MeasuringPlatformDTO.DeviceListDTO> deviceList = parentMeasuringPlatform.getDeviceList();
            BaseStationAlgorithm baseStationAlgorithm = new BaseStationAlgorithm();
            if(deviceList.size()>1){//1号测台
                log.info("1号测台物理量");
                physicalQuantityDTO.setNX(0.0);
                physicalQuantityDTO.setNZ(0.0);
                physicalQuantityDTO.setZX(0.0);
                physicalQuantityDTO.setZZ(0.0);

                //physicalQuantityDTO.setDeltaY(0.0);// 铟钢管的相对变形量( 0.0047*（CCD3后沿+CCD3前沿）/2)


                Double ccd3_after_tangential_y = attributeListDTO.stream().filter(x -> x.getKey().equalsIgnoreCase("ccd3_after_tangential_y")).findFirst().get().getValue().doubleValue();
                Double ccd3_front_tangential_y = attributeListDTO.stream().filter(x -> x.getKey().equalsIgnoreCase("ccd3_front_tangential_y")).findFirst().get().getValue().doubleValue();
               // Double deltaY = getDeformation(ccd3_after_tangential_y,ccd3_front_tangential_y);
                Double y = baseStationAlgorithm.getDeformation(ccd3_after_tangential_y,ccd3_front_tangential_y);
                physicalQuantityDTO.setY(y);// 铟钢管的相对变形量( 0.0047*（CCD3后沿+CCD3前沿）/2)
                physicalQuantityDTO.setDeltaY(0.0);




                Double ccd1_after_dip_x = attributeListDTO.stream().filter(x -> x.getKey().equalsIgnoreCase("ccd2_after_dip_y")).findFirst().get().getValue().doubleValue();
                physicalQuantityDTO.setCcd1AfterDipx(ccd1_after_dip_x);

                Double ccd1_front_dip_x = attributeListDTO.stream().filter(x -> x.getKey().equalsIgnoreCase("ccd2_front_dip_y")).findFirst().get().getValue().doubleValue();
                physicalQuantityDTO.setCcd1FrontDipx(ccd1_front_dip_x);



                Double ccd2_after_dip_y = attributeListDTO.stream().filter(x -> x.getKey().equalsIgnoreCase("ccd1_after_dip_x")).findFirst().get().getValue().doubleValue();
                Double ccd2_front_dip_y = attributeListDTO.stream().filter(x -> x.getKey().equalsIgnoreCase("ccd1_front_dip_x")).findFirst().get().getValue().doubleValue();
                physicalQuantityDTO.setCcd2AfterDipy(ccd2_after_dip_y);
                physicalQuantityDTO.setCcd2FrontDipy(ccd2_front_dip_y);


                //String dip_x_k = equipmentLabels.stream().filter(x -> x.getPropertieCode().equalsIgnoreCase("dip_x_K")).findFirst().get().getPropertieValue();
                //String dip_x_B = equipmentLabels.stream().filter(x -> x.getPropertieCode().equalsIgnoreCase("dip_x_B")).findFirst().get().getPropertieValue();
                // Double dipX = baseStationAlgorithm.getBate(Double.valueOf(dip_x_k), ccd1_after_dip_x, ccd1_front_dip_x, Double.valueOf(dip_x_B));
                //physicalQuantityDTO.setDipX(dipX);//倾角X(K*（后沿+前沿）/2 + B)
                //physicalQuantityDTO.setDipY(0.0);//倾角Y(作为计算绝对量的beta角输入)
                log.info("1号测台物理量:{}",physicalQuantityDTO);
            }else {

                Double ccd1_x_after_forward = attributeListDTO.stream().filter(x -> x.getKey().equalsIgnoreCase("ccd1_x_front_backward")).findFirst().get().getValue().doubleValue();
                Double ccd1_x_front_forward = attributeListDTO.stream().filter(x -> x.getKey().equalsIgnoreCase("ccd1_x_after_backward")).findFirst().get().getValue().doubleValue();
                Double ccd4_x_after_forward = attributeListDTO.stream().filter(x -> x.getKey().equalsIgnoreCase("ccd4_x_after_backward")).findFirst().get().getValue().doubleValue();
                Double ccd4_x_front_forward = attributeListDTO.stream().filter(x -> x.getKey().equalsIgnoreCase("ccd4_x_front_backward")).findFirst().get().getValue().doubleValue();
                //Double zx = getPhysicalQuantityFormula(ccd1_x_after_forward, ccd1_x_front_forward, ccd4_x_after_forward, ccd4_x_front_forward);
                Double zx = baseStationAlgorithm.getPhysicalQuantityFormula(ccd1_x_after_forward, ccd1_x_front_forward, ccd4_x_after_forward, ccd4_x_front_forward);
                physicalQuantityDTO.setZX(zx);//正向光束的X方向相对变形量(0.0047*（（CCD1后沿+CCD1前沿）+（CCD4后沿+CCD4前沿））/2)
                Double ccd2_z_after_forward = attributeListDTO.stream().filter(x -> x.getKey().equalsIgnoreCase("ccd2_z_after_backward")).findFirst().get().getValue().doubleValue();
                Double ccd2_z_front_forward = attributeListDTO.stream().filter(x -> x.getKey().equalsIgnoreCase("ccd2_z_front_backward")).findFirst().get().getValue().doubleValue();
                Double ccd3_z_after_forward = attributeListDTO.stream().filter(x -> x.getKey().equalsIgnoreCase("ccd3_z_after_backward")).findFirst().get().getValue().doubleValue();
                Double ccd3_z_front_forward = attributeListDTO.stream().filter(x -> x.getKey().equalsIgnoreCase("ccd3_z_front_backward")).findFirst().get().getValue().doubleValue();
                //Double zz = getPhysicalQuantityFormula(ccd2_z_after_forward, ccd2_z_front_forward, ccd3_z_after_forward, ccd3_z_front_forward);
                Double zz = baseStationAlgorithm.getPhysicalQuantityFormula(ccd2_z_after_forward, ccd2_z_front_forward, ccd3_z_after_forward, ccd3_z_front_forward);
                physicalQuantityDTO.setZZ(zz);//正向光束的Z方向相对变形量( 0.0047*（（CCD2后沿+CCD2前沿）+（CCD3后沿+CCD3前沿））/2)


                AddEquipmentRuningState.MeasuringPlatformDTO.DeviceListDTO dto = parentMeasuringPlatform.getDeviceList().get(0);
                List<AddEquipmentRuningState.MeasuringPlatformDTO.DeviceListDTO.AttributeListDTO> parentDTO = dto.getAttributeListDTO();
                Double ccd1_x_after_backward = parentDTO.stream().filter(x -> x.getKey().equalsIgnoreCase("ccd1_x_after_forward")).findFirst().get().getValue().doubleValue();
                Double ccd1_x_front_backward = parentDTO.stream().filter(x -> x.getKey().equalsIgnoreCase("ccd1_x_front_forward")).findFirst().get().getValue().doubleValue();
                Double ccd4_x_after_backward = parentDTO.stream().filter(x -> x.getKey().equalsIgnoreCase("ccd4_x_after_forward")).findFirst().get().getValue().doubleValue();
                Double ccd4_x_front_backward = parentDTO.stream().filter(x -> x.getKey().equalsIgnoreCase("ccd4_x_front_forward")).findFirst().get().getValue().doubleValue();
                Double nx = baseStationAlgorithm.getPhysicalQuantityFormula(ccd1_x_after_backward, ccd1_x_front_backward, ccd4_x_after_backward, ccd4_x_front_backward);
                physicalQuantityDTO.setNX(nx);//逆向光束的X方向相对变形量(0.0047*（（CCD1后沿+CCD1前沿）+（CCD4后沿+CCD4前沿））/2)
                Double ccd2_z_after_backward = parentDTO.stream().filter(x -> x.getKey().equalsIgnoreCase("ccd2_z_after_forward")).findFirst().get().getValue().doubleValue();
                Double ccd2_z_front_backward = parentDTO.stream().filter(x -> x.getKey().equalsIgnoreCase("ccd2_z_front_forward")).findFirst().get().getValue().doubleValue();
                Double ccd3_z_after_backward = parentDTO.stream().filter(x -> x.getKey().equalsIgnoreCase("ccd3_z_after_forward")).findFirst().get().getValue().doubleValue();
                Double ccd3_z_front_backward = parentDTO.stream().filter(x -> x.getKey().equalsIgnoreCase("ccd3_z_front_forward")).findFirst().get().getValue().doubleValue();
                Double nz = baseStationAlgorithm.getPhysicalQuantityFormula(ccd2_z_after_backward, ccd2_z_front_backward, ccd3_z_after_backward, ccd3_z_front_backward);
                physicalQuantityDTO.setNZ(nz);//逆向光束的Z方向相对变形量(0.0047*（（CCD2后沿+CCD2前沿）+（CCD3后沿+CCD3前沿））/2)

                Double ccd3_after_tangential_y = attributeListDTO.stream().filter(x -> x.getKey().equalsIgnoreCase("ccd3_after_tangential_y")).findFirst().get().getValue().doubleValue();
                Double ccd3_front_tangential_y = attributeListDTO.stream().filter(x -> x.getKey().equalsIgnoreCase("ccd3_front_tangential_y")).findFirst().get().getValue().doubleValue();
                //Double deltaY = getDeformation(ccd3_after_tangential_y,ccd3_front_tangential_y);
                Double deltaY = baseStationAlgorithm.getDeformation(ccd3_after_tangential_y,ccd3_front_tangential_y);
                physicalQuantityDTO.setDeltaY(deltaY);// 铟钢管的相对变形量( 0.0047*（CCD3后沿+CCD3前沿）/2)(4-5  用4)（5-4  用4）
                physicalQuantityDTO.setY(deltaY);//4-

                //Double ccd1_after_dip_x = attributeListDTO.stream().filter(x -> x.getKey().equalsIgnoreCase("ccd1_after_dip_x")).findFirst().get().getValue().doubleValue();
                //Double ccd1_front_dip_x = attributeListDTO.stream().filter(x -> x.getKey().equalsIgnoreCase("ccd1_front_dip_x")).findFirst().get().getValue().doubleValue();
                //String dip_x_k = equipmentLabels.stream().filter(x -> x.getPropertieCode().equalsIgnoreCase("dip_x_K")).findFirst().get().getPropertieValue();
                //String dip_x_B = equipmentLabels.stream().filter(x -> x.getPropertieCode().equalsIgnoreCase("dip_x_B")).findFirst().get().getPropertieValue();
                //Double dipX = baseStationAlgorithm.getBate(Double.valueOf(dip_x_k), ccd1_after_dip_x, ccd1_front_dip_x, Double.valueOf(dip_x_B));
                //physicalQuantityDTO.setDipX(dipX);//倾角X(K*（后沿+前沿）/2 + B)


                Double ccd1_after_dip_x = attributeListDTO.stream().filter(x -> x.getKey().equalsIgnoreCase("ccd2_after_dip_y")).findFirst().get().getValue().doubleValue();
                physicalQuantityDTO.setCcd1AfterDipx(ccd1_after_dip_x);

                Double ccd1_front_dip_x = attributeListDTO.stream().filter(x -> x.getKey().equalsIgnoreCase("ccd2_front_dip_y")).findFirst().get().getValue().doubleValue();
                physicalQuantityDTO.setCcd1FrontDipx(ccd1_front_dip_x);


                Double ccd2_after_dip_y = attributeListDTO.stream().filter(x -> x.getKey().equalsIgnoreCase("ccd1_after_dip_x")).findFirst().get().getValue().doubleValue();
                Double ccd2_front_dip_y = attributeListDTO.stream().filter(x -> x.getKey().equalsIgnoreCase("ccd1_front_dip_x")).findFirst().get().getValue().doubleValue();
                physicalQuantityDTO.setCcd2AfterDipy(ccd2_after_dip_y);
                physicalQuantityDTO.setCcd2FrontDipy(ccd2_front_dip_y);


                //String dip_y_k = equipmentLabels.stream().filter(x -> x.getPropertieCode().equalsIgnoreCase("dip_y_K")).findFirst().get().getPropertieValue();
                //String dip_y_B = equipmentLabels.stream().filter(x -> x.getPropertieCode().equalsIgnoreCase("dip_y_B")).findFirst().get().getPropertieValue();


                //Double dipY = baseStationAlgorithm.getBate(Double.valueOf(dip_y_k), ccd2_after_dip_y, ccd2_front_dip_y, Double.valueOf(dip_y_B));



                //physicalQuantityDTO.setDipY(dipY);//倾角Y(作为计算绝对量的beta角输入)
                log.info("大于1号测台物理量:{}",physicalQuantityDTO);
            }

            return physicalQuantityDTO;
        }




    }

    private BaseStationDTO.AbsoluteValueDTO getAbsoluteValue(List<AddEquipmentRuningState.MeasuringPlatformDTO.DeviceListDTO> deviceList){
        BaseStationDTO.AbsoluteValueDTO absoluteValueDTO = new BaseStationDTO.AbsoluteValueDTO();
        BaseStationAlgorithm baseStationAlgorithm = new BaseStationAlgorithm();
        absoluteValueDTO.setX(0.0);
        absoluteValueDTO.setY(0.0);
        deviceList.forEach(x->{

            List<EquipmentLabel> equipmentLabels = equipmentLabelService.list(Wrappers.<EquipmentLabel>query().lambda()
                    .eq(EquipmentLabel::getEquipmentId, x.getDeviceId()));
            DeviceTableVO deviceTableVO = iDeviceTableService.selectDeviceById(x.getDeviceId());
            List<AddEquipmentRuningState.MeasuringPlatformDTO.DeviceListDTO.AttributeListDTO> attributeListDTO = x.getAttributeListDTO();

            switch (ProductTypeEnum.getEnum(deviceTableVO.getProductId())){
                case HT_GONIOMETER://华腾绕角仪
                    Double ccd3_z_front = attributeListDTO.stream().filter(l -> l.getKey().equalsIgnoreCase("ccd3_z_front")).findFirst().get().getValue().doubleValue();
                    Double ccd3_z_after = attributeListDTO.stream().filter(l -> l.getKey().equalsIgnoreCase("ccd3_z_after")).findFirst().get().getValue().doubleValue();
                    String rich_z_K = equipmentLabels.stream().filter(l -> l.getPropertieCode().equalsIgnoreCase("rich_z_K")).findFirst().get().getPropertieValue();
                    String rich_z_B = equipmentLabels.stream().filter(l -> l.getPropertieCode().equalsIgnoreCase("rich_z_B")).findFirst().get().getPropertieValue();
                    Double gama = baseStationAlgorithm.getPhysicalQuantityDip(Double.valueOf(rich_z_K), ccd3_z_after, ccd3_z_front, Double.valueOf(rich_z_B));
                    absoluteValueDTO.setGama(0.0);//绕Z轴的旋转角
                    break;
                case HT_DOUBLE_MARKER://华腾双标仪
                    Double ccd3_z_front1 = attributeListDTO.stream().filter(l -> l.getKey().equalsIgnoreCase("ccd3_z_front")).findFirst().get().getValue().doubleValue();
                    Double ccd3_z_after1 = attributeListDTO.stream().filter(l -> l.getKey().equalsIgnoreCase("ccd3_z_after")).findFirst().get().getValue().doubleValue();
                    //Double z = getDeformation(ccd3_z_after1,ccd3_z_front1);
                    Double z  = baseStationAlgorithm.getDeformation(ccd3_z_after1,ccd3_z_front1);
                    absoluteValueDTO.setZ(0.0);
                    break;
                case HT_PERPENDICULOMETER://华腾垂线仪
                    Double ccd3_x_front = attributeListDTO.stream().filter(l -> l.getKey().equalsIgnoreCase("ccd3_x_front")).findFirst().get().getValue().doubleValue();
                    Double ccd3_x_after = attributeListDTO.stream().filter(l -> l.getKey().equalsIgnoreCase("ccd3_x_after")).findFirst().get().getValue().doubleValue();
                    String rich_x_K = equipmentLabels.stream().filter(l -> l.getPropertieCode().equalsIgnoreCase("rich_x_K")).findFirst().get().getPropertieValue();
                    String rich_x_B = equipmentLabels.stream().filter(l -> l.getPropertieCode().equalsIgnoreCase("rich_x_B")).findFirst().get().getPropertieValue();
                    Double alpha  = baseStationAlgorithm.getPhysicalQuantityDip(Double.valueOf(rich_x_K), ccd3_x_after, ccd3_x_front, Double.valueOf(rich_x_B));
                    absoluteValueDTO.setAlpha(0.0);// 绕X方向的旋转角

                    Double ccd1_y_front = attributeListDTO.stream().filter(l -> l.getKey().equalsIgnoreCase("ccd1_y_front")).findFirst().get().getValue().doubleValue();
                    Double ccd1_y_after = attributeListDTO.stream().filter(l -> l.getKey().equalsIgnoreCase("ccd1_y_after")).findFirst().get().getValue().doubleValue();
                    String rich_y_K = equipmentLabels.stream().filter(l -> l.getPropertieCode().equalsIgnoreCase("rich_y_K")).findFirst().get().getPropertieValue();
                    String rich_y_B = equipmentLabels.stream().filter(l -> l.getPropertieCode().equalsIgnoreCase("rich_y_B")).findFirst().get().getPropertieValue();
                    Double beta  = baseStationAlgorithm.getPhysicalQuantityDip(Double.valueOf(rich_y_K), ccd1_y_after, ccd1_y_front, Double.valueOf(rich_y_B));
                    absoluteValueDTO.setBeta(0.0);//绕Y方向的旋转角
                    break;
            }
        });
        return absoluteValueDTO;
    }

}
*/
